package com.itboye.eweilisten.responsitory;

import com.google.gson.reflect.TypeToken;
import com.itboye.eweilisten.model.UpdateVersionBean;
import com.itboye.eweilisten.volley.BaseErrorListener;
import com.itboye.eweilisten.volley.BaseNetRepository;
import com.itboye.eweilisten.volley.BaseSuccessReqListener;
import com.itboye.eweilisten.volley.ByJsonRequest;
import com.itboye.eweilisten.volley.ICompleteListener;

import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by boye009 on 2017/1/5.
 */

public class UpdateResponsitory extends BaseNetRepository {
    String api = "100";
    String UpdateVersion = "By_Config_app";

    public UpdateResponsitory(ICompleteListener iCompleteListener) {
        super(iCompleteListener);
    }


    public void setUpdateVersion(UpdateVersionBean bean) {
        Type type = new TypeToken<UpdateVersionBean>() {
        }.getType();
        String apiVer = api;
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("api_ver", apiVer);
        map.put("app_type", "android");

        (new ByJsonRequest.Builder<UpdateVersionBean>())
                .setTypeVerParamsAndReturnClass(UpdateVersion, apiVer, map, type)
                .requestListener(
                        new BaseSuccessReqListener<UpdateVersionBean>(getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }
}
